The action of comparison is extremely important in programming. Here are the operators you can use to carry out those comparisons.
In [10]:
# Code to display an image!
from IPython.display import Image
Image("/home/mohsin/GitHub/pythonbootcampacm/Comparison Operators/table.png")
Out[10]:
In [13]:
2 == 2
Out[13]:
In [14]:
2 != 3
Out[14]:
In [15]:
2 != 2
Out[15]:
In [1]:
2 <= 3
Out[1]:
If you completed the "Control Flow" section of the bootcamp, you have learned about "and" and "or" statements in Python. You can create expressions that render both words uneeded. While you will always use "and" along with "or", it is critical to understand all of the syntax.
In [7]:
# Normal
9 < 10 and 10 < 11
Out[7]:
In [8]:
# Chained
9 < 10 < 11
Out[8]:
In [9]:
# Alternate sign position
11 < 13 > 12
# Same as
11 <13 and 13 > 12
Out[9]: